<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>校验供应商</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
            <form id="formSet1">
            	<input name="splId" id="splId" type="hidden" value="${splId}" />
            	<input name="orgDispNm" id="orgDispNm" type="hidden" />
                <div class="fieldset1 tabel_col clearFix">
                	<div class="fieldBox col_50">
	                    <div class="label">协议编号</div>
	                    <div class="field">
	                        <input name="licNo" id="licNo" type="text" class="ui-textbox" value="" >
	                    </div>
	                </div>
                    <div class="fieldBox col_50">
	                    <div class="label">星级</div>
	                    <div class="field">
	                        <input name="lvl" id="lvl" type="text" class="ui-textbox" value="" >
	                    </div>
	                </div>
	                <div class="fieldBox col_50">
	                    <div class="label">开始日期</div>
	                    <div class="field">
	                        <input name="startDt" id="startDt" type="text" class="ui-datepicker" value="" >
	                    </div>
	                </div>
	                <div class="fieldBox col_50">
	                    <div class="label">授信额度</div>
	                    <div class="field">
	                        <input name="crAmt" id="crAmt" type="text" class="ui-textbox" value="" validate="{number:true,required:true}" >
	                        <span class="requiredSymbol">*</span>
	                    </div>
	                </div>
	                <div class="fieldBox col_50">
	                    <div class="label">结束日期</div>
	                    <div class="field">
	                        <input name="endDt" id="endDt" type="text" class="ui-datepicker" value="" >
	                    </div>
	                </div>
	                
	                <div class="fieldBox col_50">
	                    <div class="label">组织架构</div>
	                    <div class="field">
	                        
	                        <select name="orgCd" id="orgCd" data-value=" " onchange="orgCdChange(this)">
                    			<option value=" " seleted>请选择</option>
                       				<c:forEach items="${searchBuOrgList }" var="kv">
                     					<option value="${kv.key }">${kv.value }</option>
                       				</c:forEach>
                    		</select>
	                    </div>
	                </div>
	                <div class="fieldBox col_50">
	                    <div class="label">授信类型</div>
	                    <div class="field">
	                        <select name="crTypCd" id="crTypCd" data-value=" " validate="{required:true}">
                       			<c:forEach items="${searchCrTypCdList }" var="kv">
                     				<option value="${kv.key }">${kv.value }</option>
                       			</c:forEach>
                    		</select>
	                    </div>
	                </div>
                </div>
            </form>
</div>


<script type="text/javascript">
$(function(){
	var formSet1 = $('#formSet1').ligerForm({
	        validate : true
	});
    //SET_popupIframeHeight();

});
var _mfrId = '${mfrId}';

//定义父级调用事件
frameElement.dialog.onOk = function () {
	addSplCr();
}
           
frameElement.dialog.onCancel = function () {
     frameElement.dialog.close();
}
function orgCdChange(se){
	var orgDispNm = $("#orgCd").find("option:selected").text();
	if(orgDispNm == '请选择'){
		
	}else{
		$("#orgDispNm").val(orgDispNm);
	}
	
}

function addSplCr(){
	var form = liger.get("formSet1");
	if (!form.valid()) {
    	top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
        return false; //验证不通过，不执行以下代码
    }
	//var _splNm = $.trim($("#splNm").val());
	//var _bizLicNo = $.trim($("#bizLicNo").val());
	
	var data = form.getData();
	data["splId"] = $("#splId").val();
	data["orgDispNm"] = $("#orgDispNm").val();
	if(data["orgCd"] == null || data["orgCd"] == '' || data["orgCd"] == ' '){
		top.$.ligerDialog.SQalert({content: '请选择事业部' , SQ_type: "warning" });
        return false; //验证不通过，不执行以下代码
	}
	if(data["crTypCd"] == null || data["crTypCd"] == ''){
		top.$.ligerDialog.SQalert({content: '请选择授信类型' , SQ_type: "warning" });
        return false; //验证不通过，不执行以下代码
	}
	
	//发送异步请求校验
	var wait_dialog;
	$.ajax({
		type: 'post',
		dataType:'json',
		data:data,
		url: '<%=path%>/product/splCrLim/addSplCrLim.do',
		beforeSend: function(){
	          wait_dialog=top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
	     },
		success:function(msg){
			 wait_dialog.close();
			 if(msg.success == 1){
				 //top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
				 top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
				 parent.callback();
				 frameElement.dialog.close();
			 }else if(msg.success == 0 && !msg.data){//校验不成功,且没有data(id)报错
				 top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				 frameElement.dialog.close();
			 }else if(msg.success == 0 && msg.data){//校验不成功,且有返回data(id) 说明供应商存在跳转
				
			 }
		}
	});
}

</script>



</body>
</html>
